package cn.sda.leo.springStudy.service.impl;

import cn.sda.leo.springStudy.entity.Stock;
import cn.sda.leo.springStudy.mapper.StockMapper;
import cn.sda.leo.springStudy.service.StockService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * \* User: song lei
 * \* Date: 2021/6/21
 * \* Time: 11:09
 * \* Description:
 * \
 */
//需要在接口实现类中使用@Service注解，才能被SpringBoot扫描，在Controller中使用@Authwired注入
@Service
public class StockServiceImpl implements StockService {

    private final StockMapper stockMapper;
    @Autowired
    public StockServiceImpl(StockMapper stockMapper) {
        this.stockMapper = stockMapper;
    }

    @Override
    public List<Stock> findAll() {
        List<Stock> stocks = stockMapper.findAll();
        for (int i=0;i<stocks.size();i++){
            System.out.println(stocks.get(i).getFd_code());
        }
        return stocks;
    }
}
